import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios  from 'axios'

// 引入表格树形结构插件
import ZkTable from 'vue-table-with-tree-grid'

//富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
Vue.use(VueQuillEditor, /* { default global options } */)


axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// 因浏览器版本问题, 只有当token存在才会加上去，如果为空则不加(注释掉退出方法里面的clear可以验证)
axios.interceptors.request.use(
  config => {
    config.headers.Authorization = window.sessionStorage.getItem('token')
    return config
  }
)
Vue.prototype.$http = axios

import './assets/css/global.css'
// 引用了第3方 阿里图标
import './assets/fonts/iconfont.css'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import './plugins/element.js'
Vue.use(ElementUI)

// tree-table 自己定义的标签名字
Vue.component('zk-table', ZkTable)
Vue.config.productionTip = false

// vue3 过滤器已经失效了
Vue.filter('dateFormatFilter',function(originalVal){
const dt  =  new Date(originalVal)
const y = dt.getFullYear()
const m = (dt.getMonth() + 1 + '').padStart(2,'0')
const d = (dt.getDay() + '').padStart(2,'0')

const h = (dt.getHours() + '').padStart(2,'0')
const M = (dt.getMinutes() + '').padStart(2,'0')
const s = (dt.getSeconds() + '').padStart(2,'0')
 return `${y}-${m}-${d} ${h}:${M}:${s}`
})


new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
